Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add warning when using gradient_checkpointing with FSDP full shard #31578

Merged
merged 8 commits into from
Jul 9, 2024
Merged

add warning when using gradient_checkpointing with FSDP full shard #31578

merged 8 commits into from
Jul 9, 2024

Conversation

yundai424
Copy link
Contributor

What does this PR do?

Add a warning when using FSDP full shard with gradient_checkpointing training arg to encourage users to use fsdp config's activation_checkpointing instead.

Fixes #30404

Before submitting

  • This PR fixes a typo or improves the docs (you can dismiss the other checks if that's the case).
  • Did you read the contributor guideline,
    Pull Request section?
  • Was this discussed/approved via a Github issue or the forum? Please add a link
    to it if that's the case.
  • Did you make sure to update the documentation with your changes? Here are the
    documentation guidelines, and
    here are tips on formatting docstrings.
  • Did you write any new necessary tests?

Who can review?

Anyone in the community is free to review the PR once the tests have passed. Feel free to tag
members/contributors who may be interested in your PR.
@SunMarc @muellerzr

@yundai424 yundai424 changed the title add warning when using with FSDP full shard add warning when using with FSDP full shard with gradient checkpointing Jun 24, 2024
@yundai424 yundai424 changed the title add warning when using with FSDP full shard with gradient checkpointing add warning when using gradient_checkpointing with FSDP full shard Jun 24, 2024
Copy link
Member

@SunMarc SunMarc left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM @yundai424 ! Thanks a lot for adding this ! cc @muellerzr

@@ -1794,6 +1794,13 @@ def __post_init__(self):
elif FSDPOption.FULL_SHARD in self.fsdp and FSDPOption.SHARD_GRAD_OP in self.fsdp:
raise ValueError("`--fsdp full_shard` is not compatible with `--fsdp shard_grad_op`.")

if FSDPOption.FULL_SHARD in self.fsdp and self.gradient_checkpointing:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this only the case when we have FSDPOption.FULL_SHARD ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@SunMarc ah good point, hybrid shard also needs it. Update it now

@SunMarc SunMarc requested a review from amyeroberts June 25, 2024 11:32
Copy link
Collaborator

@amyeroberts amyeroberts left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for adding!

One question and one nit

src/transformers/training_args.py Outdated Show resolved Hide resolved
src/transformers/training_args.py Outdated Show resolved Hide resolved
yundai424 and others added 3 commits June 26, 2024 10:12
Co-authored-by: amyeroberts <22614925+amyeroberts@users.noreply.github.com>
Co-authored-by: amyeroberts <22614925+amyeroberts@users.noreply.github.com>
Copy link
Contributor

@muellerzr muellerzr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@HuggingFaceDocBuilderDev

The docs for this PR live here. All of your documentation changes will be reflected on that endpoint. The docs are available until 30 days after the last update.

Copy link
Collaborator

@amyeroberts amyeroberts left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for adding!

@yundai424 Running make fixup should resolve the failing quality checks on the CI

@amyeroberts amyeroberts merged commit ad35309 into huggingface:main Jul 9, 2024
20 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[FSDP] redundant additional allgather during backward when using FSDP FULL_SHARD with gradient checkpointing
5 participants